(set-auto-mode): Streamline to fix bug#67795
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 15 Mar 2024 02:15:41 +0000 (22:15 -0400)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 15 Mar 2024 02:15:41 +0000 (22:15 -0400)
commit9422a6737447b186ca017929da79985cef7898a8
treed7c71c1153159360a53486036398687b937f6d3e
parentc8c0d0a9550620adb111bf5d9e0155332498a6bf
(set-auto-mode): Streamline to fix bug#67795

The old code tested if the mode function is `fboundp` but in an
inconsistent way and without paying attention to
`major-mode-remap`.

* lisp/files.el (set-auto-mode-0): Return `:keep` rather than nil if
the mode was already set.  And emit a warning when the mode function
doesn't exist.
(set-auto-mode): Remove checks that the mode function exists now that
`set-auto-mode-0` does it for us.  Adjust to the new return values of
that function, and simplify the code using a big `or` instead of
a sequence of steps each setting&testing `done`.
(hack-local-variables--find-variables): Use `major-mode-remap`
when skipping the "mode:" entries that specify modes we don't have.
Also, when (eq handle-mode t), don't bother building a list of results
only to return a single element in the end.
lisp/files.el